package com.ssm.order.fegin.fallback;

import com.ssm.dto.CommonResult;
import com.ssm.model.stock.StockModel;
import com.ssm.order.fegin.StockFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class StockFeignFallbackFactory implements FallbackFactory<StockFeign> {

    private Logger log = LoggerFactory.getLogger(StockFeignFallbackFactory.class);


    @Override
    public StockFeign create(Throwable throwable) {
        return new StockFeign() {
            @Override
            public CommonResult<StockModel> getStockDetail() {
                log.error("调用查询库存详情降级", throwable);
                return CommonResult.error(null, -100, "调用查询库存详情降级");
            }
        };
    }
}
